import request from "../common/request.js"

const pay = (order) => {
	let data = {
		"paymentType": "wechat",
		"money": "0.01",
		"title": "wechat",
		"orderId": order.id,
		"notify_url": `http://localhost:51154/api/order/buy?id=${order.id}`,
		"return_url": `${window.location.origin}/#/pages/pay/finish?id=${order.id}`
	}
	return request({
		url: "pays",
		data,
		method: 'post'
	}).then(res=>{
		if(res.code==1) location.href = res.data.url
	})
}

export default {
	pay
}